Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting a field type with SET DATA TYPE statement in engine and Iceberg #18395

Merged
merged 2 commits into from
Aug 2, 2023

Conversation

ebyhr
Copy link
Member

@ebyhr ebyhr commented Jul 25, 2023

Description

This is the final PR about managing nested fields in the engine.
Fixes #16959

Release notes

(x) Release notes are required, with the following suggested text:

# General, Iceberg
* Support setting a field type with `SET DATA TYPE` statement. ({issue}`18395`)

@cla-bot cla-bot bot added the cla-signed label Jul 25, 2023
@github-actions github-actions bot added tests:hive iceberg Iceberg connector mongodb MongoDB connector labels Jul 25, 2023
@ebyhr ebyhr force-pushed the ebi/core-field-set-data-type branch from 783327d to 9e4b521 Compare July 25, 2023 05:59
@ebyhr ebyhr self-assigned this Jul 25, 2023
@ebyhr ebyhr force-pushed the ebi/core-field-set-data-type branch 2 times, most recently from 4982e49 to 31e4be9 Compare July 27, 2023 23:49
String caseSensitiveParentName = icebergTable.schema().findColumnName(parent.fieldId());
NestedField field = parent.type().asStructType().caseInsensitiveField(getLast(fieldPath));
if (!field.type().isPrimitiveType()) {
throw new TrinoException(NOT_SUPPORTED, "Iceberg doesn't support changing field type from non-primitive types");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to disallow type changes between primitive and nested at engine level?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we do this, connector will have to check that as well. Engine cannot do such checks atomically.

throw new TrinoException(NOT_SUPPORTED, "Unsupported type: " + type);
}
List<RowType.Field> candidates = rowType.getFields().stream()
// case-insensitive match
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be case sensitive? (eg not to get us one step further from #17)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same logic as row fields resolution in expressions as you may know.
@kasiafi requested a case-insensitive match in adding fields PR #16321 (comment).

Currently, adding & renaming fields are case-insensitive and dropping field (this was the 1st PR about managing nested fields) is case-sensitive. We should change dropping fields to case-insensitive in the near future.

String caseSensitiveParentName = icebergTable.schema().findColumnName(parent.fieldId());
NestedField field = parent.type().asStructType().caseInsensitiveField(getLast(fieldPath));
if (!field.type().isPrimitiveType()) {
throw new TrinoException(NOT_SUPPORTED, "Iceberg doesn't support changing field type from non-primitive types");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we do this, connector will have to check that as well. Engine cannot do such checks atomically.

@ebyhr ebyhr force-pushed the ebi/core-field-set-data-type branch from 31e4be9 to 4c6319e Compare August 2, 2023 02:17
@ebyhr ebyhr merged commit 6fa4e49 into trinodb:master Aug 2, 2023
92 checks passed
@ebyhr ebyhr deleted the ebi/core-field-set-data-type branch August 2, 2023 22:55
@github-actions github-actions bot added this to the 423 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed iceberg Iceberg connector mongodb MongoDB connector
Development

Successfully merging this pull request may close these issues.

Managing Nested Fields
2 participants